<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>
<div>
  <!-- v-if=true显示 false不显示
       isLogin=true表示登录过,isLogin=false 代表未登录 -->
  <div v-if="isLogin">
    <input type = "text" v-model="newName">
    <input type = "button" value="添加" @click="arr.push(newName)">
    <a href="javascript:void(0)" @click="isLogin=false">登出</a>
  </div>
  <div v-else>
    <!-- javascript:void(0)废掉跳转功能 -->
    <a href="javascript:void(0)">注册</a>
    <a href="javascript:void(0)" @click="isLogin=true">登录</a>
  </div>

  <ul>
    <li v-for="name in arr">{{name}}</li>
  </ul>
</div>
<script src="../js/vue.js"></script>
<script>
  let v = new Vue({
    el:"body>div",
    data:{
      arr:["刘备","关羽"],
      isLogin:false,
      newName:""
    }
  })
</script>
</body>
</html>